<template>
  <el-upload v-model:file-list="GetPic.inspection_Repor"
    action="http://localhost:5127/api/Manage/Upload" list-type="picture-card"
    :on-preview="handlePictureCardPreview" :on-remove="handleRemove">
    <el-icon>
      <Plus />
    </el-icon>
  </el-upload>

  <el-dialog v-model="dialogVisible">
    <img w-full :src="dialogImageUrl" alt="Preview Image" />
  </el-dialog>
</template>

<script lang="ts" setup>
import axios from 'axios';
import { ElMessage } from 'element-plus';
import { onMounted, reactive, ref } from 'vue';
import { useRouter, useRoute } from 'vue-router'
import type { TabsPaneContext } from 'element-plus'

import { Plus } from '@element-plus/icons-vue'

import type { UploadProps, UploadUserFile } from 'element-plus'

const router = useRouter()
const route = useRoute()

const GetPic = ref<any>({})

onMounted(() => {
  
  alert(route.query.batch)
  console.log(route.query.batch)
  Pic();

})
const Pic = () => {
  axios({
    url: 'http://localhost:5127/api/Manage/GetPictureInformation',
    method: 'get',
    params: {
      batch: route.query.batch
    }
  })
    .then(res => {

      console.log(res.data.data[0])
      Object.assign(GetPic, res.data.data[0])
    })
}

const dialogImageUrl = ref('')
const dialogVisible = ref(false)

const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
  console.log(uploadFile, uploadFiles)
}

const handlePictureCardPreview: UploadProps['onPreview'] = (uploadFile) => {
  dialogImageUrl.value = GetPic.value.inspection_Repor
  dialogVisible.value = true
}
</script>